Git Branches
Branches are an important part of working with Git. They allow you to isolate work into separate areas of the repository. This is useful when working on a feature or bug fix that may take a while to complete. Branches also allow you to work on multiple features or bug fixes at the same time without interfering with each other.
We use the following branch naming conventions:
-
main: The main branch of the repository. This is the branch that is deployed to production. -
develop: The development branch of the repository. This is the branch that is deployed to the staging environment. -
feature/branch-name: Use this branch for new features or enhancements. -
bugfix/branch-name: Use this branch for bug fixes. -
hotfix/branch-name: Use this branch for critical bug fixes that need to be deployed immediately. -
chore/branch-name: Use this branch for general maintenance tasks, such as updating dependencies or refactoring code.
This is a simplified Git Flow strategy: normal work is integrated in develop, production releases are promoted from develop to main, and urgent production fixes are made from main.
When working on a new feature or bug fix, create a new branch from the develop branch. When the work is complete, create a pull request to merge the changes back into the develop branch. Once the changes have been reviewed and approved, the branch can be merged into the develop branch. See Pull Requests & Code Reviews for more information on how to create and manage pull requests.
When a release is ready to be deployed to production, create a new pull request from the develop to the main branch. Once the changes have been reviewed and approved, the pull request can be merged into the main branch. The changes will then be automatically deployed to production.
When a critical bug fix is needed in production, create a new branch from the main branch called hotfix/branch-name. Once the bug fix has been tested and approved, the branch can be merged into the main branch. After the hotfix is merged into main, merge main back into develop so the fix is included in the next staging and release cycle.